package com.pzh.logistics.exception;

import com.pzh.logistics.common.ResultVO;
import com.pzh.logistics.util.ResultVOUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /**
     * 截获业务过程中手动抛出的异常
     */
    @ExceptionHandler(value = GlobalException.class)
    @ResponseBody
    public ResultVO handlerException(GlobalException e) {
        return ResultVOUtil.error(e.getCode(), e.getMessage());
    }
}
